-
Notifications
You must be signed in to change notification settings - Fork 0
Add sdJwt presentation #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Still left a couple of comments regarding unused code and stuff.
|
||
DocumentManagerSdJwt | ||
.getAllDocuments() | ||
// .filter { doc -> doc.vct == req.docType } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uncommented code, remove?
.filterIsInstance<IssuedDocument>() | ||
.filter { doc -> doc.docType == req.docType } | ||
// .filter { doc -> doc.docType == req.docType } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uncommented code, remove?
//.filterKeys { it in credentialOffer.credentialConfigurationIdentifiers } | ||
//.filterValues { credentialConfigurationFilter(it) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uncommented code, remove?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still uncommented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hab einen Kommentar drüber damit man weiß, dass das wieder rein muss
@@ -20,6 +20,7 @@ import eu.europa.ec.eudi.openid4vci.CredentialOfferRequestResolver | |||
import eu.europa.ec.eudi.wallet.issue.openid4vci.CredentialConfigurationFilter.Companion.Compose | |||
import eu.europa.ec.eudi.wallet.issue.openid4vci.CredentialConfigurationFilter.Companion.MsoMdocFormatFilter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused import.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And I also noticed, that the two fields MsoMdocFormatFilter and SdJwtFormatFilter in the CredentialConfigurationFilter are probably unused and can be removed.
// val credentialConfigurationId = | ||
// credentialIssuerMetadata.credentialConfigurationsSupported.filterValues { conf -> | ||
// credentialConfigurationFilter(conf) | ||
// }.keys.firstOrNull() ?: throw IllegalStateException("No suitable configuration found") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uncommented code, remove?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still uncommented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hab einen Kommentar drüber damit man weiß, dass das wieder rein muss
// logger?.d(TAG, "Device Response to send (hex): ${Hex.toHexString(deviceResponse)}") | ||
// logger?.d(TAG, "Device Response to send (cbor): ${CBOR.cborPrettyPrint(deviceResponse)}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uncommented code, remove?
@@ -363,7 +438,7 @@ class OpenId4vpManager( | |||
val responseUri = | |||
(this.responseMode as ResponseMode.DirectPostJwt?)?.responseURI?.toString() | |||
?: "" | |||
val nonce = this.nonce | |||
val nonce = this.nonce //TODO MAYBE THIS NONCE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a TODO. Is it still valid?
val key = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { | ||
KeyGeneratorImpl.getSigningKey(KeyGenerator.SigningKeyConfig(KeyProperties.AUTH_DEVICE_CREDENTIAL, 60)) | ||
} else { | ||
throw Exception() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe adjust to something like this?
return@runBlocking ResponseResult.Failure(AndroidException("Build version to low."))
throw IllegalArgumentException() | ||
} | ||
|
||
val namespace = "eu.europa.ec.eudi.pid.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be a constant.
val headerString = credentials.split(".").first() | ||
val headerJson = JSONObject(String(Base64.getUrlDecoder().decode(headerString))) | ||
val keyString = headerJson.getJSONArray("x5c").getString(0).replace("\n", "") | ||
println(keyString) | ||
|
||
val pemString = "-----BEGIN CERTIFICATE-----\n" + | ||
"${keyString}\n" + | ||
"-----END CERTIFICATE-----" | ||
|
||
val certificateFactory: CertificateFactory = CertificateFactory.getInstance("X.509") | ||
val certificate = | ||
certificateFactory.generateCertificate(ByteArrayInputStream(pemString.toByteArray())) as X509Certificate | ||
|
||
val ecKey = ECKey.parse(certificate) | ||
val jwtSignatureVerifier = ECDSAVerifier(ecKey).asJwtVerifier() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like I've seen this code part before in this PR... ^^
e1a417c
to
fe3a469
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did a rough review. Focused on code style / cleanup.
Looks good already, still left a few comments.
gradle/libs.versions.toml
Outdated
@@ -21,17 +22,23 @@ junit = "4.13.2" | |||
junit-android = "1.1.5" | |||
kotlin = "1.8.10" | |||
ktor = "2.3.5" | |||
#ktorClientSerialization = "2.3.6" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commented lines, remove?
gradle/libs.versions.toml
Outdated
eudi-lib-jvm-siop-openid4vp-kt = { module = "eu.europa.ec.eudi:eudi-lib-jvm-siop-openid4vp-kt", version.ref = "eudi-lib-jvm-siop-openid4vp-kt" } | ||
identity-credential = { module = "com.android.identity:identity-credential", version.ref = "identity-credential" } | ||
json = { module = "org.json:json", version.ref = "json" } | ||
junit = { module = "junit:junit", version.ref = "junit" } | ||
junit-jupiter-params = { module = "org.junit.jupiter:junit-jupiter-params", version.ref = "junit" } | ||
ktor-client-android = { module = "io.ktor:ktor-client-android", version.ref = "ktor" } | ||
ktor-client-logging = { module = "io.ktor:ktor-client-logging", version.ref = "ktor" } | ||
#ktor-client-serialization = { module = "io.ktor:ktor-client-serialization", version.ref = "ktorClientSerialization" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commented lines, remove?
wallet-core/build.gradle
Outdated
@@ -149,6 +149,7 @@ dependencies { | |||
|
|||
// Ktor Android Engine | |||
runtimeOnly libs.ktor.client.android | |||
// implementation libs.ktor.client.serialization |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commented lines, remove?
@@ -197,7 +200,9 @@ object EudiWallet { | |||
* @throws IllegalStateException if [EudiWallet] is not firstly initialized via the [init] method | |||
*/ | |||
fun deleteDocumentById(documentId: DocumentId): DeleteDocumentResult = | |||
documentManager.deleteDocumentById(documentId) | |||
documentManager.deleteDocumentById(documentId).apply { | |||
if (this is DeleteDocumentResult.Success) DocumentManagerSdJwt.deleteDocument(documentId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kurze Frage:
Waren unsere ID's jetzt gesynced, so dass das funktionieren kann?
(Oder nicht und wir müssen das noch einmal anpassen?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Die Id´s sind nicht synced, aber wir gehen davon aus, dass wir nur ein SdJwt haben können und löschen das wenn irgendein Mdoc gelöscht wird. Das ist good enough würde ich sagen. Wir sollten in die Lib noch einen Check einbauen, dass man nicht mehr als ein Pid haben kann, damit hier nichts kaputt gehen kann
//.filterKeys { it in credentialOffer.credentialConfigurationIdentifiers } | ||
//.filterValues { credentialConfigurationFilter(it) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still uncommented.
// val credentialConfigurationId = | ||
// credentialIssuerMetadata.credentialConfigurationsSupported.filterValues { conf -> | ||
// credentialConfigurationFilter(conf) | ||
// }.keys.firstOrNull() ?: throw IllegalStateException("No suitable configuration found") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still uncommented.
} else { | ||
val cborBytes = Base64.getUrlDecoder().decode(credential.credential) | ||
|
||
logger?.d(TAG, "CBOR bytes: ${Hex.toHexString(cborBytes)}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's only debug level, but I think we should remove this logger here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Der logger ist aus der originalen lib selbst, den haben wir nicht selbst hinzugefügt, aber ich kann ihn entfernen
return entry | ||
} | ||
|
||
private const val SIGNATURE_ALGORITHM = "SHA256withECDSA" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe move up (line 23/24) to the other constants in this file?
val vpToken = | ||
Base64.getUrlEncoder().withoutPadding() | ||
.encodeToString(deviceResponse) | ||
logger?.d(TAG, "VpToken: $vpToken") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this really be logged?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Der logger ist aus der originalen lib selbst, den haben wir nicht selbst hinzugefügt
No description provided.